package day05;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/14
 */
public class ImageFormat {
    public static void main(String[] args) {
        String str = "image.png";
        System.out.println("图片格式为"+getImageFormat(str));
    }

    public static String getImageFormat(String imageName) {
        if (imageName == null || imageName.isEmpty()) {
            return "";
        }

        // 没有扩展名或点号在最后
        int Index = imageName.lastIndexOf('.');
        if (Index == -1 || Index == imageName.length() - 1) {
            return "";
        }

        return imageName.substring(Index + 1);
    }

}
